package com.source.lightfowl.config;

import com.source.lightfowl.interceptor.LoginInterceptor;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Author: xcy
 * @Date:Create：in 2020/9/11 20:33
 * @Description:
 */

/*
@Component
public class MvcConfig extends WebMvcConfigurerAdapter {

    //@Autowired
    //private LoginInterceptor loginInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
    }
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //指定拦截器类
        InterceptorRegistration it = registry.addInterceptor(new LoginInterceptor());
        //一些页面不拦截
        it.excludePathPatterns("/") //添加不拦截路径
                .excludePathPatterns("/login.html") //添加不拦截路径
                .excludePathPatterns("/index.html") //添加不拦截路劲
                .excludePathPatterns("/error.html") //添加不拦截路劲

                //登陆请求不拦截
                .excludePathPatterns("/person/login") //添加不拦截路径
                .excludePathPatterns("//loginuser")
                .excludePathPatterns("//person/login")
                .excludePathPatterns("/checkOprate")//鉴权请求

                //静态资源不拦截
                .excludePathPatterns("/login.html") //添加不拦截路径
                .excludePathPatterns("/assets/**") //添加不拦截路径
                .excludePathPatterns("/plugins/**") //添加不拦截路径

                //添加拦截路径
                .addPathPatterns("/**");  //添加拦截路径

    }
}*/
